home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / RUN.TST / CNTRUNS.C < prev    next >
C/C++ Source or Header  |  1995-12-09  |  1KB  |  61 lines

  1. /* ============ */
  2. /* cntruns.c    */
  3. /* ============ */
  4. #include <rundefs.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8. /* ==================================================================== */
  9. /* CountRuns - Counts runs in RandArray                 */
  10. /* ==================================================================== */
  11. void
  12. CountRuns(RUN_DATA_STRU *RunData)
  13. {
  14.     long    DtaIdx = -1;
  15.  
  16.     memset(RunData->RunCtrs, 0, sizeof(RunData->RunCtrs));
  17.  
  18.     while (DtaIdx < (long) RunData->ActRandCount - 1)
  19.     {
  20.     long    RunCtr = 0;
  21.  
  22.     do
  23.     {
  24.         ++RunCtr;
  25.         ++DtaIdx;
  26.  
  27.         if (DtaIdx >= (long) RunData->ActRandCount)
  28.         {
  29.         break;
  30.         }
  31.     }
  32.     while (RunData->RandArray[DtaIdx] < RunData->RandArray[DtaIdx + 1]);
  33.  
  34.     if (RunCtr > 6)
  35.     {
  36.         RunCtr = 6;
  37.     }
  38.  
  39.     ++RunData->RunCtrs[0];
  40.     ++RunData->RunCtrs[RunCtr];
  41.  
  42.     /* ---------------------------- */
  43.     /* Throw away the element that    */
  44.     /* immediately follows a run.    */
  45.     /* ---------------------------- */
  46.     ++DtaIdx;
  47.  
  48.     if (DtaIdx >= (long) RunData->ActRandCount-1)
  49.     {
  50.         if (DtaIdx == (long) RunData->ActRandCount-1)
  51.         {
  52.         ++RunData->RunCtrs[0];
  53.         ++RunData->RunCtrs[1];
  54.         }
  55.         break;
  56.     }
  57.     }                    /* end while */
  58.  
  59.     RunData->CallStatus = TRUE;
  60. }
  61.